package com.lxh.cp.config;

import lombok.Data;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * created by lanxinghua@2dfire.com on 2020/2/22
 */
@Configuration
@Data
@Order(0) // 优先启动
public class JedisConfiguration {
    private static final String host = "192.168.99.100";
    private static final int port = 6379;

    @Bean
    public JedisPool getJedisPool(){
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(50);
        config.setMaxIdle(5);
        config.setMaxWaitMillis(1000*100);
        return new JedisPool(config, host, port,  2000, null);
    }

    public static void main(String[] args) {
        System.out.println(new JedisConfiguration().getJedisPool().getResource().ping());
    }
}
